<template>
  <a-modal
    :visible="visible"
    title="调课"
    okText='保存'
    :width="700"
    @cancel="() => { $emit('cancel') }"
    @ok="comfirm"
  >
    <a-form :form="form">
      <a-row>
<!--        <a-col>
        <a-form-item
          label="开课院系"
          :labelCol="{span: 7,offset: 1}"
          :wrapperCol="{span: 15, offset: 1}"
        >
          <a-select disable v-decorator="['kkyxm',
                {
                  rules: [{ required: true, message: '请选择培养单位!' }],
                }]" @change="yxChange" showSearch :filterOption="filterOption" >
            <a-select-option v-for="i in selectMenu.yxList" :key="i.id" :value="i.dwh">{{ i.dwh }} {{ i.dwmc }}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="课程名称"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select disable v-decorator="['kcbm',
                {
                  rules: [{ required: true, message: '请选择课程!' }],
                }]" @change="kcChange" showSearch :filterOption="filterOption" >
              <a-spin v-if="kcLoading" slot="notFoundContent" size="small"/>
              <a-select-option v-for="(i,index) in selectMenu.courseList" :key="index" :value="i.kch">{{ i.kcmc }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="学分"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['xf']" disabled/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="上课年级"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select disable disable v-decorator="['sknj',
                {
                  rules: [{ required: true, message: '请选择上课年级!' }],
                }]">
              <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="总学时"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['xs']" disabled/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="开课学年"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select disable disable v-decorator="['kkxn',
                {
                  rules: [{ required: true, message: '请选择开课学年!' }],
                }]">
              <a-select-option v-for="i in TYPE0125" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="开课学期"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select disable v-decorator="['kkxqm',
                {
                  rules: [{ required: true, message: '请选择开课学期!' }],
                }]">
              <a-select-option v-for="i in TYPE0072" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="上课周类型"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select disable v-decorator="['skzlxm',
                {
                  rules: [{ required: true, message: '请选择上课周类型!' }],
                }]">
              <a-select-option v-for="i in TYPE0343" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="上课周"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['skz',
                {
                  rules: [{ required: true, message: '请输入上课周!' }],
                }]"/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="开始周"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['ksz',
                {
                  rules: [{ required: true, message: '请输入开始周!' }],
                }]"/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="结束周"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['jsz',
                {
                  rules: [{ required: true, message: '请输入结束周!' }],
                }]"/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="开始课节"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['kskj',
                {
                  rules: [{ required: true, message: '请输入开始课节!' }],
                }]"/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="结束课节"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['jskj',
                {
                  rules: [{ required: true, message: '请输入结束课节!' }],
                }]"/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="班级名称"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['jxbh',
                {
                  rules: [{ required: true, message: '请输入班级名称!' }],
                }]"/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="最大选课人数限定"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['xkrsxd',
                {
                  rules: [{ required: true, message: '请输入听课人数!' }],
                }]"/>
          </a-form-item>
        </a-col>
        <a-col :md="8" :sm="12">
          <a-form-item
            label="最小选课人数限定"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input disable v-decorator="['xkrsxdMin',
                {
                  rules: [{ required: true, message: '请输入听课人数!' }],
                }]"/>
          </a-form-item>
        </a-col>-->
        <a-col :md="16" :sm="24">
          <a-form-item
            label="备注"
            :labelCol="{span: 3,offset: 1}"
            :wrapperCol="{span: 17, offset: 1}"
          >
            <a-textarea v-decorator="['note',
              {
                rules: [{ required: true, message: '请填写备注!' }],
              }]"/>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </a-modal>
</template>

<script>
export default {
  props: ['visible'],
  data () {
    return {
      pkxxId: '',
      note: ''
    }
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
    if(this.note){
      this.form.setFieldsValue({note: this.note})
    }
  },
  methods:{
    comfirm () {
      this.form.validateFields((err, values) => {
        if (err) {
          return
        }
        this.$api.cultivate.adjusting({
          pkxxId: this.pkxxId,
          note: values.note
        }).then(res => {
          this.$message.success(res.msg)
          this.$emit('cancel')
          this.$emit('refresh')
        })
      })
    }
  }
}
</script>

<style>

</style>
